import { createStore, createLogger } from 'vuex'
import user from '@/store/user'
import { RootStateInterface } from './rootStateInterface'
import projectRoter from '../../config/projectStore';
import * as TYPES from './types'
const debug = process.env.NODE_ENV !== 'production'
export default createStore<RootStateInterface>({
  state: {
    language: ''
  },
  getters: {
    getLanguage(state): string {
      const language: string = sessionStorage.getItem('language') || '中文' 
      state.language = language
      return state.language
    }
  },
  mutations: {
    // 存入语言
    [TYPES.SET_LANGUAGE](state, language: string) {
      state.language = language;
      sessionStorage.setItem('language',state.language)
    },
  },
  actions: {
  },
  modules: {
    user,
    projectRoter
  },
  plugins: debug ? [createLogger()] : []
})